package com.efuture.mutlithread;

/**
 * @ClassNAME ThreadJoin
 * @Description join()方法，线程合并，让当前线程处于阻塞的状态，参与合并的线程执行完毕，才会执行当前线程
 * @Author zhaoshanshan
 * @Date 2021/9/11 10:25 上午
 * @Version 1.0
 */
public class ThreadJoin {
    public static void main(String[] args) {
        System.out.println("main begin");
        ThreadJoinTest t = new ThreadJoinTest();
        t.setName("t");
        t.start();
        try {
            t.join();//阻塞当前main线程 让t线程执行 t线程执行完毕 才会执行main线程
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("main over");
    }
}
class ThreadJoinTest extends Thread{
    @Override
    public void run() {

       for (int i = 0;i<10000;i++){
           System.out.println(Thread.currentThread().getName()+":"+i);
       }
    }
}